<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
	<button>计算</button>
	<button>假死</button>
	<button>开辟线程</button>
</body>
<script>
	const btns = document.querySelectorAll("button");
	btns[0].onclick = function(){
		let num = 0;
		console.log("开始计算");
		for(let i=0;i<999999999;i++){
			num+=Math.random();
		}
		console.log("结束：",num)
	}
	btns[1].onclick = function(){
		console.log("你现在看到我了！")
	}
	btns[2].onclick = function(){
		if(window.Worker){
			const worker = new Worker("./lib/my.js");
			worker.onmessage=function (e){
				console.log(e.data)
			}
			worker.postMessage(99999999)
		}else{
			console.log("不支持Worker")
		}
	}
</script>
</html>